/*
 * Filename : TimerWatcher.java
 * Description : **COMPLETE**
 * History  : Date               Engineer       Description
 *            ---------          ------------   --------------------------------
 *            September 24, 2007      waitek         Initial creation.
 */

package com.lct.eq2.watchers;

import com.lct.eq2.data.*;
import com.lct.eq2.gui.TimerWindow;

public class SpellTimerWatcher extends Thread implements Runnable {
    private boolean interrupted = true;
    private double delay;
    private double mult;
    private int spellCountPosition;
    private String spellName;
    private TimerWindow parent;
    
    /** Creates a new instance of TimerWatcher */
    public SpellTimerWatcher(double delay, String spellName, TimerWindow parent, int spellCountPosition, double mult) {
        this.mult = mult;
        this.spellCountPosition = spellCountPosition;
        this.interrupted = false;
        this.spellName = spellName;
        this.delay = delay;
        this.parent = parent;
        this.start();
    }
    
    public void stopRunning() {
        this.interrupted = true;
    }

    public int getSpellCountPosition() {
        return this.spellCountPosition;
    }
    
    public TimerWindow getParent() {
        return this.parent;
    }
    
    public String getSpellName() {
        return this.spellName;
    }
    
    public double getDelay() {
        return this.delay;
    }
    
    public double getMultiplier() {
        return this.mult;
    }
    
    public void run() {
        double count = (delay * this.mult);
        boolean swiped = false;
        if (mult > 1) {
           swiped = true; 
        }
        while (!this.interrupted && (count >= 0)) {
            this.parent.createTimerGraph(this.spellName, count, (delay * this.mult), this.spellCountPosition, swiped);
            try {
                this.currentThread().sleep(1000);
            } catch (InterruptedException ex) {
                ex.printStackTrace();
            }
            count--;
        }
    }
}
